$(document).ready(init);

function init() {
	showContent({
		appType : 0
	});
	
	$('#search').click(doSearch);
}

function doSearch() {
	showContent({
		appType : 0,
		startTime : $.trim($('#startTime').val()),
		endTime : $.trim($('#endTime').val())
	});
	
}

/**
 * 显示信息
 */
function showContent(queryParams) {
	$('#appointments').datagrid({
	    title:'',
	    iconCls:'icon-save',
	    singleSelect:true,
	    url:'appointment-admin!queryAppointmentsInPage.action',
	    idField: 'id',
	    queryParams :queryParams,
	    frozenColumns:[[
	     	{field:'appName',title:'仪器名称',width:fixWidth(0.12)},
	        {field:'operatNo',title:'订单号',width:fixWidth(0.16),align:'center'}
	    ]],
	    columns:[[
	        {field:'appName',title:'仪器名称',width:fixWidth(0.12)},
	        {field:'operatNo',title:'订单号',width:fixWidth(0.16),align:'center'},
	        {field:'empName',title:'真实姓名',width:fixWidth(0.07)},
	        {field:'loginAccount',title:'登陆账号',width:fixWidth(0.08)},
	        {field:'phone',title:'联系方式',width:fixWidth(0.08),align:'center'},
	        {field:'startTime',title:'预约开始时间',width:fixWidth(0.1),align:'center'},
	        {field:'endTime', title:'预约结束时间',width:fixWidth(0.1),align:'center'},
	        {field:'checkStatus',title:'状态',width:fixWidth(0.1),align:'center',
	        	    formatter : function(value, rowData, rowIndex) {
						if (value == 1) {
							return '待审核';
				 		}
				 		else if (value == 2) {
							return '课题组长审核通过';
				 		} 
				 		else if (value == 3) {
							return '课题组长审核拒绝';
				 		} 
				 		else if (value == 4) {
							return '管理员审核通过';
				 		} 
				 		else if (value == 5) {
							return '管理员审核拒绝';
				 		} else {
				 			return '未知'
				 		}
					}
			},
			{field:'useType',title:'使用情况',width:fixWidth(0.066),align:'center',
	        	    formatter : function(value, rowData, rowIndex) {
						if (value == 1) {
							return '预约';
				 		} 
				 		else if (value == 2) {
							return '超时使用';
				 		} 
				 		else if (value == 3) {
							return '超时未用';
				 		} 
				 		else if (value == 4) {
							return '已经使用';
				 		} else {
				 			return '未知'
				 		}
					}
			},
			{field:'remark', title:'备注', width:fixWidth(0.13)}
	    ]],
	    nowrap:false,
	    pagination:true,
	    rownumbers:true
	});
}